import request from '@/utils/request'

export function interpret(code) {
  return request({
    method: 'post',
    url: '/code',
    data: { code }
  })
}

export function judge(code, userId, problemId) {
  return request({
    method: 'post',
    url: '/judge_code',
    data: { code, userId, problemId }
  })
}

export function getCodes(userId) {
  return request({
    method: 'get',
    url: '/code',
    params: { userId }
  })
}

export function clearCodes(userId) {
  return request({
    method: 'delete',
    url: '/code',
    data: { userId }
  })
}

export function deleteCode(codeId) {
  return request({
    method: 'delete',
    url: '/code',
    data: { codeId }
  })
}
